// import { createPinia } from 'pinia';
import * as Pinia from 'pinia'  
import piniaPersist from 'pinia-plugin-persist-uni';

// 自动注入所有pinia模块
const files = import.meta.globEager('./*.js');
// console.log('files',files);
const modules = {};
Object.keys(files).forEach((key) => {
  modules[key.replace(/(.*\/)*([^.]+).*/gi, '$2')] = files[key].default;
});
// console.log(modules);

export const setupPinia = (app) => {
  // const pinia = createPinia();
  // pinia.use(piniaPersist);
  // app.use(pinia);
  
  
  const pinia=Pinia.createPinia();
  app.use(pinia);
  pinia.use(piniaPersist);
 
};

export default (name) => {
  return modules[name]();
};
